{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python_defaultSpec_1599487821518",
   "display_name": "Python 3.8.5 64-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "给定一个字符串，请你找出其中不含有重复字符的 最长子串 的长度。\n",
    "\n",
    "示例 1:\n",
    "\n",
    "输入: \"abcabcbb\"\n",
    "输出: 3 \n",
    "解释: 因为无重复字符的最长子串是 \"abc\"，所以其长度为 3。\n",
    "示例 2:\n",
    "\n",
    "输入: \"bbbbb\"\n",
    "输出: 1\n",
    "解释: 因为无重复字符的最长子串是 \"b\"，所以其长度为 1。\n",
    "示例 3:\n",
    "\n",
    "输入: \"pwwkew\"\n",
    "输出: 3\n",
    "解释: 因为无重复字符的最长子串是 \"wke\"，所以其长度为 3。\n",
    "     请注意，你的答案必须是 子串 的长度，\"pwke\" 是一个子序列，不是子串。\n",
    "\n",
    "来源：力扣（LeetCode）\n",
    "链接：https://leetcode-cn.com/problems/longest-substring-without-repeating-characters\n",
    "著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 暴力法\n",
    "\n",
    "以`pwwkew`为例子，先从p开始找，到`pww`的时候有重复的字符的，所以是2，然后从索引为1的`w`开始找，找到有重复的就退出。复杂度为$O(n^{2})$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "优化一下\n",
    "\n",
    "先从索引为0的`p`开始找，当找到索引2的`w`时，就有重复了，我们从索引为3的地方继续找\n",
    "\n",
    "提交了之后发现没通过`dvdf`，在第二个d的时候，应该放弃第一个而从"
   ]
  }
 ]
}